import {
  createRouter, createWebHashHistory, RouteRecordRaw
} from 'vue-router';
import nprogress from 'nprogress';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'app',
    component: () => import('@/views/menu/index.vue'),
    redirect: { path: '/forecast' },
    children: [
      {
        path: '/manage',
        name: 'manage',
        component: () => import('@/views/manage/index.vue')
      },
      {
        path: '/forecast',
        name: 'forecast',
        component: () => import('@/views/forecast/index.vue')
      },
      {
        path: '/portrayal',
        name: 'portrayal',
        component: () => import('@/views/manage/index.vue')
      },
      {
        path: '/analyze',
        name: 'analyze',
        component: () => import('@/views/manage/index.vue')
      },
      {
        path: '/rules',
        name: 'rules',
        component: () => import('@/views/manage/index.vue')
      },
      {
        path: '/settings',
        name: 'settings',
        component: () => import('@/views/manage/index.vue')
      },
      {
        path: '/intelligent',
        name: 'intelligent',
        component: () => import('@/views/intelligent/index.vue')
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

router.beforeEach((from, to, next) => {
  nprogress.start();
  next();
});

router.afterEach(() => {
  nprogress.done();
});

export default router;
